home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
DESKTOP
/
SWIPE.ZIP
/
!Swipe
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1998-10-25
|
14KB
|
541 lines
Swipe
Thomas Leonard
Program and modifications requested by Jon Wright (Jonix)
Version 0.01 - First test version (useable).
(23/10/97)
Version 0.02 - Can grab from non-indirected window titles.
(25/10/97) Colour scheme now black/white.
Version 0.03 - Added save icon which can be dragged to save.
(30/10/97) Can also swipe right to left now.
Version 0.04 - Moved text icon to the left.
(01/11/97) Double click selects a whole word.
Dragging with nothing selected the whole string is saved.
Version 0.05 - String width calculations now work for pre-RO3.5 machines.
(02/11/97) Dragging with nothing selected selects the whole string.
Version 0.06 - Doesn't put a CR on the end of the text!
(27/7/98)
Version 0.07 - Doesn't quit if you release the keys while swiping.
(04/9/98) Easier to change the keys.
Version 0.08 - Double clicking now actually claims the clipboard
(15/9/98) (thanks to Jonathan Hunt for spotting this!).
Might work on pre-3.5 machines.
Saved scrap files now typed to Text.
Version 0.09 - Releasing keys while dragging text icon doesn't abort
(25/10/98) the drag (needed for old versions of Zap).
Key numbers can be found in the StrongHelp manual:
OS -> OS -> Claim -> vector number -> EventV -> Event number
-> Key transition -> key number
',HotKey1 = 76 :
Default 76 = Left Shift
(*HotKey2 = 94 :
Default 94 = Left Alt
$+" (error code "+
messages 28
-)messages!0=&400c2 :
task initialise
messages!4=&f
messages!8=&10
messages!12=1
messages!16=2
messages!20=3
messages!24=0
swipe_text 256
?swipe_text=0
TASK 4
$TASK="TASK"
"Wimp_Initialise",300,!TASK,"Swipe",messages
WimpVersion%,Task_Handle%
=5Swipe_Box%=-1 :
window handle (not created yet)
assembler
@8Clipboard_Data$=
13 :
(we don't own the clipboard)
block 256
Finished=
E(Dragging=
: Swiping=1 : Text_Icon=2
Dragging=Swiping
Mask=1<<22
Mask=(1<<22)+1
"Wimp_Poll",Mask,block,,poll_word
Reason%
Reason%
J7
0 :
Dragging = Swiping
null_drag_box
K#
1 :
redraw_swipe_box
L7
6 :
mouse_click(block!0,block!4,block!8)
7 :
drag_box
13 :
do_our_job
O)
17,18 :
user_message(block!16)
Finished
"OS_Release",&10,key_event,0 :
remove our code from the event vector
"OS_Byte",13,11 :
disable key events
"OS_Module",7,,RMA_block :
remove our code from the RMA
"Wimp_CloseDown",Task_Handle%,!TASK
assembler
Length%=88
this code can be called at any time so it must go in the module area
"OS_Module",6,,,Length%
,,RMA_block
P%=RMA_block
L%=RMA_block+Length%
`,sp=13:lk=14:
define some register names
[OPT 8
.key_status
equd 3
.poll_word
f: equd 0 ;(1 = close box, 2 = open box)
; => r0 = event type
.key_event
j3 teq r0,#11 ;key event?
k= movnes pc,lk ;no - not for us then
stmfd (sp)!,{r0,lk}
m2 teq r2,#HotKey1 ;L-Shift ?
n; moveq r14,#1 ;yes - change bit 0
oD movne r14,#2 ; no - change bit 1 (if any)
p0 teqne r2,#HotKey2 ;L-Alt ?
qL ldmnefd (sp)!,{r0,pc}^ ;not one of our keys - pass event on
ldr r0,key_status
s8 teq r1,#1 ;key down event?
biceq r14,r0,r14
u= orrne r14,r0,r14 ;r14 = new key status
str r14,key_status
w; teq r14,#0 ;all keys now down?
xA teqne r0,#0 ;no - all keys were down?
yO ldmnefd (sp)!,{r0,pc}^ ;no - just update key_status and return
add r14,r1,#1
{: str r14,poll_word ;set the poll word
|: ldmfd (sp)!,{r0,pc}^ ;pass the event on
"OS_Byte",14,11 :
enable key events
"OS_Claim",&10,key_event,0 :
add our code to the event vector
do_our_job
Action=!poll_word
!poll_word=0
Action
1 :
close_swipe_box
2 :
open_swipe_box
close_swipe_box
Swipe_Box%<>-1
!block=Swipe_Box%
"Wimp_DeleteWindow",,block
Swipe_Box%=-1
Dragging = Swiping
Dragging =
"Wimp_DragBox",, -1
open_swipe_box
"Wimp_GetPointerInfo",,block
1$swipe_text=
read_data(block!12,block!16)+
?swipe_text<32
$swipe_text="(Adjust to paste)"
close_swipe_box
(scan string to find width)
Width=
width($swipe_text)+32
X,Y,Z
win_def=block+4
+win_def!0=X-32 : win_def!4=Y-32
,win_def!8=X+Width+64-32: win_def!12=Y+32
)win_def!16=-8-64 : win_def!20=0
1win_def!24=-1 : win_def!28=&80000000
/win_def!32=&01070207 : win_def!36=&0c0103
+win_def!40=-8-64 : win_def!44=-64
)win_def!48=Width : win_def!52=0
>win_def!56=&27000000 : win_def!60=10<<12 :
button type
)win_def!64=1 : win_def!68=0
.win_def!84=1 :
only icon (the save icon)
+win_def!88=-72 : win_def!92=-60
+win_def!96=-8 : win_def!100=-4
:win_def!104=&1700301a : $(win_def+108)="small_fff"+
"Wimp_CreateWindow",,win_def
Swipe_Box%
!block=Swipe_Box%
"Wimp_OpenWindow",,block
!Swipe_From=-100:Swipe_To=-100
read_data(Win%,Icon%)
Icon%=-4
read_title(Win%)
block!12=Win%
block!16=Icon%
"Wimp_GetIconState",,block+12 :
get info on icon under pointer
Flags=block!36
Flags
Flags
1<<8
data is indirected
"Wimp_SendMessage",19,block,block!12,block!16
,,Her_Handle%
"XWimp_TransferBlock",Her_Handle%,block!40,Task_Handle%,block,255
1<<28
Data$=
Data$=
strip(block)
data is not indirected
block?52=0
Data$=
strip(block+40)
=Data$
read_title(Win%)
!block=Win%
"Wimp_GetWindowInfo",,block+1
Flags=block!60
Flags
Flags
1<<8
data is indirected
"Wimp_SendMessage",19,block,Win%
,,Her_Handle%
"XWimp_TransferBlock",Her_Handle%,block!76,Task_Handle%,block,255
1<<28
Data$=
Data$=
strip(block)
data is not indirected
block?88=0
Data$=
strip(block+76)
=Data$
user_message(Message%)
Message%
0 : Finished=
1 :
load_clipboard
2 :
data_save_ack
3 :
load_clipboard2
&f :
other_claims_clipboard
&10 :
data_request
&400c2 :
strip(block+28)="Swipe"
block!4<>Task_Handle%
Finished=
strip(Addr%)
I$=""
?Addr%>31
(I$)<255
I$+=
?Addr%
Addr%+=1
say(Message$)
"Wimp_ReportError","xxxx"+Message$,%101,"Swipe"
redraw_swipe_box
icon=block+64
"OS_ReadModeVariable",-1,4
,,XEig%
!icon!0=-2<<XEig% : icon!4=-64
icon!8=Width : icon!12=0
icon!16=&17000111
icon!20=swipe_text
icon!24=-1
"Wimp_RedrawWindow",,block
Flag
/XMin=Swipe_From+block!4-block!20+(1<<XEig%)
Eor_Col=
choose_col
Flag<>0
"Wimp_PlotIcon",,icon
3,Eor_Col
XMin,block!8,Swipe_To-Swipe_From,block!16-block!8
"Wimp_GetRectangle",,block
Flag
invert
block!0=Swipe_Box%
block!8=-64
Swipe_From>Swipe_To
block!4=Swipe_To+4
block!12=Swipe_From
block!4=Swipe_From
block!12=Swipe_To+4
block!16=0
"Wimp_UpdateWindow",,block
Flag
/XMin=Swipe_From+block!4-block!20+(1<<XEig%)
Eor_Col=
choose_col
Flag<>0
3,Eor_Col
XMin,block!8,Swipe_To-Swipe_From,block!16-block!8
"Wimp_GetRectangle",,block
Flag
mouse_click(X%,Y%,Buttons%)
block!16=0
drag_icon:
Buttons%
&100 :
paste
&4 :
select_word
&40 :
start_swipe
select_word
!block=Swipe_Box%
"Wimp_GetWindowState",,block
Win_MiX=block!4
Win_MiY=block!8
Win_MaX=block!12
Win_MaY=block!16
invert
"OS_ReadModeVariable",-1,4
,,XEig%
9-Swipe_From=X%-block!4-(2<<XEig%)+block!20
; Index=
get_index(Swipe_From)
Index_To=Index
Index>0
alpha(
$swipe_text,Index,1))
Index-=1
Index_To<
($swipe_text)
alpha(
$swipe_text,Index_To+1,1))
Index_To+=1
D*Swipe_From=
width(
$swipe_text,Index))
E+Swipe_To=
width(
$swipe_text,Index_To))
invert
I8Clipboard_Data$=
$swipe_text,Index+1,Index_To-Index)
block!0=24
block!12=0
block!16=&f
N%block!20=1<<2 :
claim clipboard
"Wimp_SendMessage",17,block,0
alpha(Char$)
Char$>="A"
Char$<="Z"
Char$>="a"
Char$<="z"
Char$>="0"
Char$<="9"
start_swipe
!block=Swipe_Box%
"Wimp_GetWindowState",,block
Win_MiX=block!4
Win_MiY=block!8
Win_MaX=block!12
Win_MaY=block!16
invert
"OS_ReadModeVariable",-1,4
,,XEig%
b-Swipe_From=X%-block!4-(2<<XEig%)+block!20
d Index=
get_index(Swipe_From)
Index_To=Index
Swipe_To=Swipe_From
invert
block!4=7
block!8=X% : block!12=Y%
block!16=X% : block!20=Y%
m)block!24=Win_MiX+8 : block!28=Win_MiY
n)block!32=Win_MaX : block!36=Win_MaY
"Wimp_DragBox",,block
Dragging=Swiping
round XPos to a letter boundary
get_index(
XPos)
Index,WFont%
WimpVersion% >= 350
"Wimp_ReadSysInfo",8
WFont%
z' WFont% = 0 :
System font always
WFont%=0
XPos<0
XPos=0
~: Index=XPos>>4 :
offset of first letter into string
Index>
($swipe_text)
Index=
($swipe_text)
XPos=Index<<4
XPos<0
XPos=0
"Font_ScanString",WFont%,swipe_text,(1<<8),XPos*400,&fff
,Index,,end
Index-=swipe_text
XPos=end/400
=Index
null_drag_box
"Wimp_GetPointerInfo",,block
Old_Swipe_To=Swipe_To
Swipe_To=block!0+block!20
block!0=Swipe_Box%
"Wimp_GetWindowState",,block
Swipe_To-=block!4
!Index_To=
get_index(Swipe_To)
Old_Swipe_To=Swipe_To
Swipe_To,Old_Swipe_To
invert
Swipe_To,Old_Swipe_To
invert
drag_box
Dragging
Text_Icon
'
"Wimp_GetPointerInfo",,block
/ block!20=block!12 :
dest window, icon
block!24=block!16
block!16=1 :
DataSave
# block!36=
(Clipboard_Data$)
block!40=&fff
# $(block+44)="SwipedText"+
block!0=56
block!12=0
8
"Wimp_SendMessage",17,block,block!20,block!24
Swiping
,
Index_To<Index
Index,Index_To
< Clipboard_Data$=
$swipe_text,Index+1,Index_To-Index)
block!0=24
block!12=0
block!16=&f
) block!20=1<<2 :
claim clipboard
(
"Wimp_SendMessage",17,block,0
Dragging=
other_claims_clipboard
((block!20)
(1<<2))
block!4<>Task_Handle%
Clipboard_Data$=
data_request
((block!36)
(1<<2))=0
Clipboard_Data$=
we don't own the clipboard
block!0=52
block!12=block!8
block!16=1
block!36=
(Clipboard_Data$)
block!40=&fff
$(block+44)="Swiped"+
"Wimp_SendMessage",17,block,block!4
data_save_ack
SavePath$=
strip(block+44)
(SavePath$)
#C,Clipboard_Data$;
"SetType "+SavePath$+" Text"
block!12=block!8
block!16=3
block!36=
(Clipboard_Data$)
"Wimp_SendMessage",17,block,block!4
paste
Clipboard_Data$<>
we own the clipboard, so this'll be easy
A%=1
(Clipboard_Data$)
4
"OS_Byte",&99,0,
Clipboard_Data$,A%,1))
send a request for the clipboard data
block!0=48
block!12=0
block!16=&10
block!20=-1
block!24=-1
block!36=4
, block!40=&fff :
we only want text...
block!44=-1
"XWimp_SendMessage",17,block,0
load_clipboard
block!4=Task_Handle%
block!0=60
block!12=block!8
block!16=2
block!36=-1
!$(block+44)="<Wimp$Scrap>"+
"Wimp_SendMessage",17,block,block!4
load_clipboard2
strip(block+44))
C=0
B%=
B%=10
B%=13
"OS_Byte",&99,0,B%
"Remove "+
strip(block+44)
choose_col
"OS_ReadModeVariable",-1,3
,,Colours%
Colours%>16
=63
drag_icon
4block!8=block!0 :
drag box is the click point
block!12=block!4
"DragASprite_Start",%1000101,1,"small_fff",block
Dragging=Text_Icon
Swipe_From<0
nothing selected - select everything
! Clipboard_Data$=$swipe_text
invert:
just in case
) Index=0:Index_To=
(Clipboard_Data$)
Swipe_From=0
& Swipe_To=
width(Clipboard_Data$)
invert
block!0=24
block!12=0
block!16=&f
' block!20=1<<2 :
claim clipboard
"Wimp_SendMessage",17,block,0
width(S$)
WFont%,Width%
WimpVersion% >= 350
"Wimp_ReadSysInfo",8
WFont%
' WFont% = 0 :
System font always
WFont%=0
(S$)<<4
"Wimp_TextOp",1,S$,0
Width%
=Width%